package com.itheima.anno;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/demo21")
public class ServletDemo21 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext sc = getServletContext();
        //代表发布项目的根目录
        String realPath = sc.getRealPath("/");
        System.out.println(realPath);
        String realPath1 = sc.getRealPath("/b.txt");
        System.out.println(realPath1);
        String realPath2 = sc.getRealPath("/WEB-INF");
        System.out.println(realPath2);
        String realPath3 = sc.getRealPath("/WEB-INF/classes/a.txt");
        System.out.println(realPath3);
    }
}
